﻿using System;
using System.Collections.Generic;
using Token.Piker.Core.Security;
using Token.Piker.Core.Tag;
using Token.Piker.Core.Album;

namespace Token.Piker.Web.AJAX
{
    /// <summary>
    /// GetUploadInfo 的摘要说明
    /// </summary>
    public class GetUploadInfo : BaseAjaxHandler
    {

        protected class AlbumTemplate
        {
            public string aid;
            public string name;
        }

        protected override void Mapping()
        {
            OprationMap["getAlbum"] = "GetAlbum";
            OprationMap["getTpyeCont"] = "GetTpyeCont";
            OprationMap["getTpyeStyle"] = "GetTpyeStyle";
        }
        /// <summary>
        ///获取相册信息
        /// </summary>
        public void GetAlbum()
        {
            //获取用户ID
            if (CurrentUser == null)
            {
                IsSuccess = false;
                return;
            }
            string uid = CurrentUser.Id;
            if (uid == string.Empty || uid == null)
            {
                IsSuccess = false;
                return;
            }
            try
            {
                IsSuccess = true;
                var list_src = AlbumProxy.GetAlbumList("UserID = " + uid);
                List<AlbumTemplate> list = new List<AlbumTemplate>();
                foreach (var item in list_src)
                {
                    AlbumTemplate temp = new AlbumTemplate();
                    temp.aid = Convert.ToString(item.ID);
                    temp.name = item.AlbumName;
                    list.Add(temp);
                }
                ResponseTemplate(list);
            }
            catch
            {
                IsSuccess = false;
            }
           

        }
        /// <summary>
        /// 获取内容分类的类型
        /// </summary>
        public void GetTpyeCont()
        {
            try
            {
                var list = TagProxy.GetTagList("Flag = 0");  //内容分类
                IsSuccess = true;
                ResponseTemplate(list);
            }
            catch
            {
                IsSuccess = false;
            }
            

        }

        /// <summary>
        /// 获取风格分类的类型
        /// </summary>
        public void GetTpyeStyle()
        {
            try
            {
                var list = TagProxy.GetTagList("Flag = 1");  //内容分类
                IsSuccess = true;
                ResponseTemplate(list);
            }
            catch
            {
                IsSuccess = false;
            }
        }
    }
}